/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.actions;

import robocup.component.worldobjects.Player;

/**
 * This action performs an attentionto-command. This is an instant-action,
 * which causes the player to concentrate on the aural messages sent by the
 * specified player. 
 */
public class AttentionToAction extends Action {

	/**
	 * The player, on which the attention is set.
	 */
	private Player communicator;

	/**
	 * The teamname of the corresponding player.
	 */
	private String teamName;

	/**
	 * Constructor, sets the player to whom the attention should be set.
	 * 
	 * @param player -
	 *            the player to whom the attention should be set
	 * @param teamname -
	 *            the name of the team of the given player
	 */
	public AttentionToAction(Player player, String teamName) {
		super();
		this.communicator = player;
		this.teamName = teamName;
		this._type = Action.TYPE.ATTENTIONTO;
	}

	/**
	 * Empty Constructor
	 */
	public AttentionToAction() {
		super();
	}

	/**
	 * This method translates the action into a String, which is a valid command
	 * for the server of the format: (attentionto &lt;TeamName&gt; &lt;Number&gt;)
	 */
	@Override
	public String toString() {
		if (this.communicator == null)
			return "(attentionto off)";
		StringBuffer str = new StringBuffer();
		str.append("(attentionto ");
		str.append(this.teamName);
		str.append(" ");
		str.append(this.communicator.getNumber());
		str.append(")");
		return str.toString();
	}

	/**
	 * returns the player to whom the attention should be set.
	 * 
	 * @return Player - the communicator.
	 */
	public Player getCommunicator() {

		return this.communicator;
	}

	/**
	 * @return Returns the teamName.
	 */
	public String getTeamName() {

		return this.teamName;
	}

}